package com.sap.sap_mangers.until;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


/**
 * @author AdongYi
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SimpleJson {
    public static final SimpleJson SUCCESS = new SimpleJson(0, "操作成功");
    public static final SimpleJson FAILURE = new SimpleJson(1, "操作失败");
    public static final SimpleJson NULL_FAILURE = new SimpleJson(2, "空指针错误");
    public static final SimpleJson AUTHORITY_FAILURE = new SimpleJson(3, "权限不足");
    public static final SimpleJson DO_NOTHING = new SimpleJson(4, "什么也没有改变");
    public static final SimpleJson NOT_LOGIN_FAILURE = new SimpleJson(5, "未登录");
    public static final SimpleJson COME_FAILURE_TO_SUCCESS = new SimpleJson(6, "遇到了错误，但被系统更正了！最终操作成功");
    /**
     * 0为成功
     */
    private int code = 0;
    /**
     * 返回的提示
     */
    private String msg = "";
    private Object data;

    public SimpleJson(String msg) {
        //单独输入msg默认失败
        this.code = 1;
        this.msg = msg;
    }

    public SimpleJson(Object o) {
        this.code = 0;
        this.msg = "获取成功";
        this.data = o;
    }

    public SimpleJson(int code) {
        this.code = code;
    }

    public SimpleJson(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public SimpleJson(int code, Object o) {
        this.code = code;
        this.msg = "获取成功！";
        this.data = o;
    }

    public static SimpleJson buildData(Object o) {
        return new SimpleJson(0, "操作成功", o);
    }

    public static SimpleJson buildFailData(Object o) {
        return new SimpleJson(1, "操作失败", o);
    }


}
